<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="qury" value="&ftype=${ ftype }&fkey=${ fkey }" />
<c:set var="burl" value="?cpage=" />
<div id="contents">
<form id="meminfo" method="get">
	<fieldset>
		<legend>회원 정보 조회<span>총 회원 수 : ${ total_member }</span></legend>
		<c:if test="${ chg eq 'y' }">
			<c:if test="${ result eq 'success' }">
				<div class="alert alert-success alert-dismissable">
				  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
				  <strong>회원 정보를 삭제 하였습니다.</strong>
				</div>
			</c:if>
			<c:if test="${ result eq 'fail' }">
				<div class="alert alert-danger alert-dismissable">
				  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
				  <strong>회원 정보를 삭제하지 못하였습니다.</strong> 다시 시도해 주세요.
				</div>
			</c:if>
		</c:if>
		<div id="center">
			<div id="findbox">
				<select id="ftype" name="ftype" class="form-control">
					<option value="">분류</option>
					<option value="uid">아이디</option>
					<option value="uname">이름</option>
					<option value="phone">핸드폰</option>
					<option value="email">이메일</option>
				</select>
				<label for="fkey">검색어</label>
				<input type="text" id="fkey" name="fkey" class="form-control" placeholder="검색어를 입력하세요" />
				<button type="submit" id="fbtn" class="btn btn-primary">검색</button>
			</div>
			<div id="infotb" class="clear">
				<table class="table table-hover">
					<colgroup>
						<col width="64px" />
						<col width="100px" />
						<col width="85px" />
						<col width="140px" />
						<col />
						<col width="120px" />
						<col width="126px" />
						<col width="82px"/>	
						<col width="80px" />				
					</colgroup>
					<thead>
						<tr>
							<th><a href="${burl}${cpage}${qury}&orderNum=1">회원번호</a></th>
							<th><a href="${burl}${cpage}${qury}&orderNum=2">아이디</a></th>
							<th><a href="${burl}${cpage}${qury}&orderNum=3">이름</a></th>
							<th><a href="${burl}${cpage}${qury}&orderNum=4">핸드폰</a></th>
							<th><a href="${burl}${cpage}${qury}&orderNum=5">이메일</a></th>
							<th><a href="${burl}${cpage}${qury}&orderNum=6">주소</a></th>
							<th><a href="${burl}${cpage}${qury}&orderNum=7">선호 장르</a></th>
							<th><a href="${burl}${cpage}${qury}&orderNum=0">가입일</a></th>
							<th></th>
						</tr>
					</thead>
					<tbody>
					<c:forEach var="m" items="${ member_list }">
						<tr>
							<td>${ m.mno }</td>
							<td>${ m.uid }</td>
							<td>${ m.uname }</td>
							<td>${ m.phone }</td>
							<td>${ m.email }</td>
							<td>${ m.addr.split(' ')[0] }${ m.addr.split(' ')[1] }</td>
							<td><select id="ugenre"><option>${ m.ugenre1 }</option>
									<option>${ m.ugenre2 }</option></select></td>
							<td>${ m.rdate.substring(0,10) }</td>
							<td><button type="button" class="btn btn-warning mbtn" onclick="modifyMem(${m.mno})">수정</button>
								<button type="button" class="btn btn-danger dbtn" onclick="deleteMem(${m.mno})">삭제</button></td>
						</tr>
					</c:forEach>
					</tbody>
					<tfoot>
						<tr><td colspan="9">
							<ul class="pagination">
							<c:if test="${ cpage ne 1 }">
								<li><a href="${burl}${cpage-1}${qury}">&laquo;</a></li>
							</c:if>
							<c:if test="${ cpage eq 1 }">
								<li class="disabled"><a href="#">&laquo;</a></li>
							</c:if>
							<c:forEach var="p" begin="${startnav}" end="${startnav+9}">
								<c:if test="${p le allpage}">
									<c:if test="${p eq cpage}">
									<li class="active"><a href="#">${p} <span class="sr-only">(current)</span></a></li>
									</c:if>
									<c:if test="${p ne cpage}">
									<li><a href="${burl}${p}${qury}">${p}</a></li>
									</c:if>
								</c:if>
							</c:forEach>
								<li><a href="${ burl }${cpage+1 }${ qury }">&raquo;</a></li>
							</ul>						
						</td></tr>
					</tfoot>
				</table>				
			</div>		
		</div>
	</fieldset>
</form>
</div>
<script>
	$("#fbtn").submit(function(){
		var ftype = $("#ftype").val();
		var fkey = $("#fkey").val();
		location.href = "?ftype=" + ftype + "&fkey" + fkey;
	});
</script>
<script>
	var mno;
	function modifyMem(mno) {
		location.href="adm_mem_modify.bi?mno=" + mno;
	}
	function deleteMem(mno) {		
		location.href="adm_mem_delete.bi?mno=" + mno;
	}
</script>
